//
//  GYUserNoLoginTopView.m
//  research
//
//  Created by 章鱼 on 17/3/28.
//  Copyright © 2017年 simon. All rights reserved.
//

#import "GYUserNoLoginTopView.h"

@interface GYUserNoLoginTopView ()
@property (nonatomic, strong) UIImageView *backgroundView;
@property (nonatomic, strong) UIImageView *pictureView;
@property (nonatomic, strong) UIButton *resigerButton;
@property (nonatomic, strong) UIButton *loginButton;



@end

@implementation GYUserNoLoginTopView

- (instancetype)init {
    
    self = [super init];
    if (self) {
        [self creatPreLiveViewUI];
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        [self creatPreLiveViewUI];
    }
    return self;
}

- (void)dealloc {
    
}

- (void)drawRect:(CGRect)rect {
    [super drawRect:rect];
}
- (void)layoutSublayersOfLayer:(CALayer *)layer {
    [super layoutSublayersOfLayer:layer];
    
}

- (void)creatPreLiveViewUI {
    _backgroundView = [[UIImageView alloc] init];
    [self addSubview:_backgroundView];
    _backgroundView.image = [UIImage imageNamed:@"personal center_img_backgroud"];
    _backgroundView.userInteractionEnabled = YES;
    
    _pictureView = [[UIImageView alloc] init];
    [_backgroundView addSubview:_pictureView];
    _pictureView.layer.cornerRadius = 32.5f *ADJUST_SCREEN_HEIGHT_SCALE;
    _pictureView.layer.masksToBounds = YES;
    _pictureView.userInteractionEnabled = YES;
    _pictureView.contentMode = UIViewContentModeScaleToFill;
    _pictureView.image = [UIImage imageNamed:@"personal center_icon_avatar"];
    
    _resigerButton = [[UIButton alloc] init];
    [_backgroundView addSubview:_resigerButton];
    [_resigerButton setTitle:@"注册" forState:UIControlStateNormal];
    [_resigerButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    _resigerButton.titleLabel.font = [UIFont systemFontOfSize:15];
    _resigerButton.titleLabel.textAlignment = NSTextAlignmentCenter;
    [_resigerButton setBackgroundColor: [UIColor orz_textAssist]];
    [_resigerButton addTarget:self action:@selector(resigerClick:) forControlEvents:UIControlEventTouchUpInside];
    _resigerButton.layer.cornerRadius = 3.f;
    _resigerButton.layer.masksToBounds = YES;
    
    
    _loginButton = [[UIButton alloc] init];
    [_backgroundView addSubview:_loginButton];
    [_loginButton setTitle:@"登录" forState:UIControlStateNormal];
    [_loginButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    _loginButton.titleLabel.font = [UIFont systemFontOfSize:15];
    _loginButton.titleLabel.textAlignment = NSTextAlignmentCenter;
    [_loginButton setBackgroundColor: [UIColor orz_mainColor]];
    [_loginButton addTarget:self action:@selector(loginClick:) forControlEvents:UIControlEventTouchUpInside];
    _loginButton.layer.cornerRadius = 3.f;
    _loginButton.layer.masksToBounds = YES;
    
    
    [_backgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0.f);
        make.left.mas_equalTo(0.f);
        make.right.mas_equalTo(0.f);
        make.bottom.mas_equalTo(0.f);
        
    }];
    
    [_pictureView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(20.f);
        make.centerX.mas_equalTo(_backgroundView.mas_centerX);
        make.size.mas_equalTo(CGSizeMake(65*ADJUST_SCREEN_HEIGHT_SCALE, 65*ADJUST_SCREEN_HEIGHT_SCALE));
        
    }];
    
    [_resigerButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_pictureView.mas_bottom).offset(20.f);
        make.left.mas_equalTo((SCREEN_WIDTH-20)/2-80);
        make.size.mas_equalTo(CGSizeMake(80*ADJUST_SCREEN_WIDTH_SCALE, 30*ADJUST_SCREEN_HEIGHT_SCALE));
        
    }];
    
    [_loginButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_pictureView.mas_bottom).offset(20.f);
        make.left.mas_equalTo((SCREEN_WIDTH)/2+10);
        make.size.mas_equalTo(CGSizeMake(80*ADJUST_SCREEN_WIDTH_SCALE, 30*ADJUST_SCREEN_HEIGHT_SCALE));
        
    }];
    
}

- (void)resigerClick:(UIButton *)btn{
    if (self.resigerBlock) {
        self.resigerBlock();
    }
}

- (void)loginClick:(UIButton *)btn {

    if (self.loginBlock) {
        self.loginBlock();
    }
}


@end
